package com.hex.ds.hdtp.core.app.data.table.converter;

import com.hex.ds.hdtp.core.app.data.table.dto.request.TableTransferFieldMapRequestDto;
import com.hex.ds.hdtp.core.app.data.table.dto.response.TableTransferFieldMapResponseDto;
import com.hex.ds.hdtp.core.inf.data.table.po.TableTransferFieldMapPo;
import com.hex.ds.hdtp.core.inf.metadata.entity.TableFieldsEntity;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

/**
 * @Package com.hex.ds.hdtp.core.app.data.table.converter
 * @ClassName ITableTransferFieldMapConverter
 * @Description 表迁移清单字段映射-DTO对象转PO对象转换器
 * @Author Wang zhihao
 * @Date 2023/8/9 11:57
 * @Version v1.0
 **/
@Mapper(componentModel = "spring")
public interface ITableTransferFieldMapConverter {

    /**
     * @Method toTableTransferFieldMapPo
     * @Param
     * @param tableTransferFieldMapRequestDto
     * @Return com.hex.ds.hdtp.core.inf.data.table.po.TableTransferFieldMapPo
     * @Description RequestDto对象转Po对象
     * @Author Wang zhihao
     * @Date 2023/8/9 11:56
     * @Version V1.0
     */
    TableTransferFieldMapPo toTableTransferFieldMapPo(TableTransferFieldMapRequestDto tableTransferFieldMapRequestDto);

    /**
     * @Method toTableTransferFieldMapResponseDtoList
     * @Param
     * @param tableTransferFieldMapPos
     * @Return java.util.List<com.hex.ds.hdtp.core.app.data.table.dto.response.TableTransferFieldMapResponseDto>
     * @Description PO对象集合转换ResponseDto对象集合
     * @Author Wang zhihao
     * @Date 2023/8/9 11:57
     * @Version V1.0
     */
    List<TableTransferFieldMapResponseDto> toTableTransferFieldMapResponseDtoList(List<TableTransferFieldMapPo> tableTransferFieldMapPos);

    /**
     * @Method toTableFieldsEntity
     * @Param
     * @param tableTransferFieldMapList
     * @Return java.util.List<com.hex.ds.hdtp.core.inf.metadata.entity.TableFieldsEntity2>
     * @Description 生成表结构信息集合
     * @Author Wang zhihao
     * @Date 2023/8/11 17:56
     * @Version V1.0
     */
    List<TableFieldsEntity> toTableFieldsEntityList(List<TableTransferFieldMapResponseDto> tableTransferFieldMapList);

    /**
     * @Method toTableFieldsEntity
     * @Param
     * @param tableTransferFieldMap
     * @Return com.hex.ds.hdtp.core.inf.metadata.entity.TableFieldsEntity2
     * @Description 生成表结构信息
     * @Author Wang zhihao
     * @Date 2023/8/13 23:14
     * @Version V1.0
     */
    @Mappings({
            @Mapping(target = "columnName", source = "targetFieldName"),
            @Mapping(target = "columnType", source = "targetFieldType"),
            @Mapping(target = "columnCommet", source = "targetComment"),
            @Mapping(target = "columnLength", source = "targetFieldLength"),
            @Mapping(target = "partitioningColumn", source = "isPartitionField"),
            @Mapping(target = "isPrimaryKey", source = "isMajorKey"),
            @Mapping(target = "isAllowNull", source = "isAllowNull"),
            @Mapping(target = "partitionFieldName", source = "partitionFieldMapping")
    })
    TableFieldsEntity toTableFieldsEntity(TableTransferFieldMapResponseDto tableTransferFieldMap);

    /**
     * @Method toFieldMapRequestDtoList
     * @Param
     * @param tableFieldsEntities
     * @Return java.util.List<com.hex.ds.hdtp.core.app.data.table.dto.request.TableTransferFieldMapRequestDto>
     * @Description 表结构信息集合转为表迁移字段映射集合
     * @Author Wang zhihao
     * @Date 2023/8/15 10:38
     * @Version V1.0
     */
    List<TableTransferFieldMapRequestDto> toFieldMapRequestDtoList(List<TableFieldsEntity> tableFieldsEntities);

    /**
     * @Method toFieldMapRequestDto
     * @Param
     * @param tableFieldsEntity
     * @Return com.hex.ds.hdtp.core.app.data.table.dto.request.TableTransferFieldMapRequestDto
     * @Description 表结构信息转为表迁移字段映射
     * @Author Wang zhihao
     * @Date 2023/8/15 10:39
     * @Version V1.0
     */
    @Mappings({
            @Mapping(target = "sourceFieldName", source = "columnName"),
            @Mapping(target = "sourceFieldType", source = "columnType"),
            @Mapping(target = "sourceComment", source = "columnCommet"),
            @Mapping(target = "sourceFieldLength", source = "columnLength"),
            @Mapping(target = "isPartitionField", source = "partitioningColumn"),
            @Mapping(target = "isMajorKey", source = "isPrimaryKey"),
            @Mapping(target = "isAllowNull", source = "isAllowNull"),
            @Mapping(target = "targetComment", source = "columnCommet")
    })
    TableTransferFieldMapRequestDto toFieldMapRequestDto(TableFieldsEntity tableFieldsEntity);

}
